<template>
	<view>
		<map name="" :latitude="latitude" :longitude="longitude"></map>

		<button @click="getLocation">获取位置</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude: 0,
				longitude: 0
			};
		},
		methods: {
			getLocation() {
				uni.getLocation({
					success: resp => {
						console.log(resp)
						const {
							latitude,
							longitude
						} = resp;
						this.latitude = latitude
						this.longitude = longitude
					},
					fail: error => {
						console.log(error)
					}
				})

			}
		},
		onLoad() {
			this.getLocation()

		}
	}
</script>

<style lang="scss">

</style>